<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <link href="/custom.css" rel="stylesheet"/>

    <meta charset="UTF-8">
    <title>采集的URL列表</title>

</head>
<body>

<br>

<br>

<div>
    <input id="deleteSelected" type="button" value="批量删除"> <input id="favoriteSelected" type="button" value="收藏选中">
</div>

<br>

<div class="tableList">
    <table>
        <!--<caption>URL列表</caption>-->
        <thead><!--表格头-->
        <tr>
            <th><input id="checkAll" type="checkbox"></th>
            <th>操作</th>
            <th>id</th> <!--加粗标题-->
            <th>页面名称</th>
            <th>url地址</th>
            <th>源url地址</th>
            <th>创建时间</th>
            <th>修改时间</th>
            <th>修改版本</th>
        </tr>
        </thead>

        <tbody><!--表格体-->
        <tr th:each="url:${spideUrls}">
            <td><input type="checkbox" th:value="${url.id}"></td>
            <td><a href="" th:href="@{|/spide/saveToFavorite/${url.id}}">收藏</a>
            </td>
            <td th:text="${url.id}"></td>
            <td><a href="" th:href="@{|${url.url}|}" th:text="${url.urlTitle}"></a></td>
            <td><a href="" th:href="@{|${url.url}|}" th:text="${url.url}" target="_blank"></a></td>
            <td><a href="" th:href="@{|${url.spideUrl}|}" th:text="${url.spideUrl}" target="_blank"></a></td>
            <td [[${#dates.format(${url.createTime},yyyy-MM-dd hh:mm:ss)}]]></td>
            <td th:text="${url.updatedTime}"></td>
            <td th:text="${url.seq}"></td>
        </tr>
        </tbody>
    </table>
</div>
</body>

<script src="/jquery-1.8.0.js" charset="utf-8"></script>

<script>
    $(function () {

        var check = false;
        $("#checkAll").click(function () {
            // alert("click");
            if (check == false) {
                $("input[type='checkbox']").attr("checked", true);
                check = true;
            } else {
                $("input[type='checkbox']").attr("checked", false);
                check = false;
            }
        });

        $("#deleteSelected").click(function () {
            var ids = $("input[type='checkbox']:checked").map(function () {
                var value = $(this).val();
                if (value != "on") {
                    return value;
                }
                return;
            }).get().join(",");
            alert(ids);
            window.location.href = "/spide/delete?ids=" + ids;
        });


        $("#favoriteSelected").click(function () {
            var ids = $("input[type='checkbox']:checked").map(function () {
                var value = $(this).val();
                if (value != "on") {
                    return value;
                }
                return;
            }).get().join(",");
            alert(ids);
            window.location.href = "/spide/favorite?ids=" + ids;
        });
    })
</script>
</html>